package fc.testmain;

import cn.hutool.http.HttpRequest;
import fc.FcHttpCon;
import fc.entity.OaEntity;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class HJ_CREATE1 {
    public static void main(String[] args) {
        OaEntity oe=new OaEntity();
        oe.setREQUESTID("20250410181300000003");

        oe.setTYPENO("YHJ01");//单据类别
        oe.setJUDGE1("N");//用来判断

        oe.setUSERID("MW17071100690");//人员
        oe.setDEPARTMENTID("1000034");//部门
        oe.setCUS_NO("S07039");//供应商编号
        oe.setCUR_ID("CNY");//币别
        oe.setTAX_NO("T08");//税种
        oe.setFKTJ("A20");//付款条件
        oe.setJYTJ("CFR");//交易条件
        oe.setSXRQ("2025/04/10");//生效日期

        //oe.setUP("");//单价

        //这里赋值
        DateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String  timestamp= format.format(new Date());
        DateFormat formataa = new SimpleDateFormat("yyyy-MM-dd");
        String createdate = formataa.format(new Date());
        String creater="MW17071100690";
        String bumen="1000034";
        //judge1 来判断委外一般

        oe.setREQUESTID(timestamp);


        String json_param=
                "{"+
                        "\"key\": \"a3b67072afa24b1e5d15e6486dd83bc8\","+
                        "\"type\": \"sync\","+
                        "\"host\": {"+
                        "\"prod\": \"OAPI\","+
                        "\"ip\": \"10.100.96.96\","+
                        "\"lang\": \"zh_CN\","+
                        "\"timestamp\": \""+timestamp+"\","+
                        "\"acct\": \"tiptop\""+
                        "},"+
                        "\"service\": {"+
                        "\"prod\": \"T100\","+
                        "\"name\": \"oapi.po.pricing.crt\","+
                        "\"ip\": \"10.100.96.96\","+
                        "\"id\": \"topprod\""+
                        "},"+
                        "\"datakey\": {"+
                        "\"EntId\": \"23\","+
                        "\"CompanyId\": \"ZH00\","+
                        "\"doc_type_no\": \""+oe.getTYPENO()+"\",   "+ //YJH01是标准采购核价，YHJ02是委的， YHJ03是委外返修的，必填
                        "\"item_no\": \"\""+
                        "},"+
                        "\"payload\": {"+
                        "\"std_data\": {"+
                        "\"parameter\": {"+
                        "\"enterprise_no\": \"23\", "+//必给，与上面ENTID一致
                        "\"site_no\": \"ZH00\","+
                        "\"is_digiwin_product\": \"Y\","+
                        "\"pricing_list_master\": ["+
                        "{"+
                        "\"source_no\": \""+oe.getREQUESTID()+"\",   "+//来源单号， 每次提次不可以相同，必填
                        "\"doc_type_no\": \""+oe.getTYPENO()+"\", "+ //必填，与上面一致
                        "\"outsourcing_type\": \""+oe.getJUDGE1()+"\",   "+//是否是委外，必填
                        "\"doc_date\": \""+createdate+"\",  "+//必填
                        "\"applicant_no\": \""+creater+"\",  "+ //申请人，必填
                        "\"application_department\": \""+bumen+"\",   "+//申请人所在部门编号，必填
                        "\"supplier\": \""+oe.getCUS_NO()+"\",  "+ //供应商编号，必填
                        "\"currency_no\": \""+oe.getCUR_ID()+"\","+//，必填
                        "\"tax_no\": \""+oe.getTAX_NO()+"\",   "+//税种，必填
                        "\"payment_condition\": \""+oe.getFKTJ()+"\",   "+//付款条件，必填
                        "\"trade_condition\": \""+oe.getJYTJ()+"\",  "+//交易条件，必填
                        "\"approval_content\": \"1\","+
                        "\"effective_date\": \""+oe.getSXRQ()+"\", "+  //生效开始日，必填
                        "\"expiration_date\": \"\","+
                        "\"price_valuation_target_control\": \"1\","+
                        "\"price_valuation_control\": \"1\","+
                        "\"is_qty_valuation\": \"N\",  "+//分量计价否
                        "\"remark\": \"主要备注//\","+
                        "\"modify_no\": \""+creater+"\","+
                        "\"create_date\": \""+createdate+"\","+
                        "\"doc_approve_set\": \"N\","+
                        "\"pricing_list_detail\": ["+
                        "{"+
                        "\"seq_no\": \"1\",  "+//序号，同一单不可以相同，必填
                        "\"item_no\": \"121007002920\",  "+//料号，必填
                        "\"item_feature_no\": \" \","+
                        "\"series_no\": \"\","+
                        "\"item_category\": \"\","+
                        "\"vendor_item_no\": \"\","+
                        "\"program_job_no\": \"\","+
                        "\"op_seq\": \"\","+
                        "\"process_no\": \"\","+
                        "\"reason_code\": \"\","+
                        "\"unit\": \"PCS\",   "+//物料单位，必填
                        "\"currency_no\": \"CNY\","+//，必填
                        "\"tax_no\": \"T08\",  "+//税种，必填
                        "\"remark\": \"明细备注1\","+
                        "\"price\": \"4199.9\",  "+//单价，必填
                        "\"is_qty_valuation\": \"N\",  "+ //是否分量计，必填（若这里为Y，则下面的分量明细必填，否则分量计价明细里面可以为空）
                        "\"pricing_valuation_detail\": ["+
                        "{"+
                        "\"price\": \"4199\",  "+ //分量价格
                        "\"discount_rate\": \"0\",   "+//默认， 0
                        "\"start_quotation_qty\": \"0.001\",  "+ //分量的开始数量
                        "\"end_quotation_qty\": \"9999\"    "+//分量的结束数量
                        "},"+
                        "{"+
                        "\"price\": \"4190\","+//  分量价格
                        "\"discount_rate\": \"0\",  "+//默认0
                        "\"start_quotation_qty\": \"9999.001\",  "+ //分量的开始数量
                        "\"end_quotation_qty\": \"9999999\"   "+ //分量的结束数量
                        "}"+
                        "]"+
                        "},"+
                        "{"+
                        "\"seq_no\": \"2\","+
                        "\"item_no\": \"120407000233\","+
                        "\"item_feature_no\": \" \","+
                        "\"series_no\": \"\","+
                        "\"item_category\": \"\","+
                        "\"vendor_item_no\": \"\","+
                        "\"program_job_no\": \"\","+
                        "\"op_seq\": \"\","+
                        "\"process_no\": \"\","+
                        "\"reason_code\": \"\","+
                        "\"unit\": \"PCS\","+
                        "\"currency_no\": \"CNY\","+
                        "\"tax_no\": \"T08\","+
                        "\"remark\": \"明细备注2\","+
                        "\"price\": \"4299\","+
                        "\"is_qty_valuation\": \"N\","+
                        "\"pricing_valuation_detail\": ["+
                        "{"+
                        "\"price\": \"4299\","+
                        "\"discount_rate\": \"0\","+
                        "\"start_quotation_qty\": \"0.001\","+
                        "\"end_quotation_qty\": \"9999\""+
                        "},"+
                        "{"+
                        "\"price\": \"4290\","+
                        "\"discount_rate\": \"0\","+
                        "\"start_quotation_qty\": \"9999.001\","+
                        "\"end_quotation_qty\": \"9999999\""+
                        "}"+
                        "]"+
                        "}"+
                        "]"+
                        "}"+
                        "]"+
                        "}"+
                        "}"+
                        "}"+
                        "}";

        String data = HttpRequest.post(FcHttpCon.ZH_YFSY_XQ).body(json_param).execute().body();

        System.out.println(data);

    }
}
